<template>
  <el-table-column
      :label="label"
      :prop="prop"
      :width="width || ''"
      :header-align="headerAlign"
      :align="align"
      :fixed="fixed"
      :min-width="minWidth"
  >
    <template slot-scope="scope">
      {{map.get(scope.row[prop])}}
    </template>
  </el-table-column>
</template>

<script>
export default {
  name: "TransformTextColumn",
  props: {
    label: {
      type: String,
      default() {
        return ''
      }
    },
    prop: {
      type: String,
      default() {
        return ''
      }
    },
    width: {
      type: String,
      default() {
        return ''
      }
    },
    minWidth: String,
    headerAlign: {
      type: String,
      default() {
        return ''
      }
    },
    align: {
      type: String,
      default() {
        return 'center'
      }
    },
    fixed: String,
    // 转换规则([[转换前，转换后],....])
    transformRule: Array
  },
  data() {
    return {
      map: null
    }
  },
  created() {
    this.map = new Map(this.transformRule)
  }
}
</script>

<style scoped>

</style>
